package com.leetcode.LC;

public class LC852 {
    public int peakIndexInMountainArray(int[] arr) {
        int i = 0;
        for (; i < arr.length - 1; i++)
            if (arr[i] > arr[i + 1]) break;
        return i;
    }

    public int peakIndexInMountainArray2(int[] arr) {
        int a = 0, b = arr.length - 1, mid;
        while (a < b) {
            mid = a + (b - a) / 2;
            if (arr[mid] > arr[mid + 1]) {
                b = mid;
            } else {
                a = mid + 1;
            }
        }

        return a;
    }
}
